package com.ymatou.iapi.godmch.testcase;

import java.util.Map;

import org.apache.commons.collections.map.HashedMap;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.common.collect.Lists;
import com.ymatou.iapi.godmch.parameter.getMchInfoForProductDetailBean;
import com.ymatou.iapi.godmch.parameter.setBizConfigBean;
import com.ymatou.iapi.godmch.service.getMchInfoForProductDetailCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.utils.TestDataManager;
/**
*商户详情(买家端查询)
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getMchInfoForProductDetail{
	private static getMchInfoForProductDetailBean bean;
	private static getMchInfoForProductDetailCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商户详情(买家端查询)");
	}

	@Before
	public void caseUp() {
		bean=new getMchInfoForProductDetailBean();
		call=new getMchInfoForProductDetailCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchInfoForProductDetail_001() {
		Logger.start(true,"商户详情(买家端查询)-biz_key存在");
		try {
			
			setBizConfigBean setBizConfigBean=GodmchManageCallService.initSetBizConfig();
			
	       // Integer bizId=Integer.parseInt(TestDataManager.getRandomNum(5));
	        Integer bizId=GodmchManageCallService.CreateSellerMch();
	        String key="key_"+TestDataManager.getRandomNum(5);
	        String value="value"+TestDataManager.getRandomNum(5);
			Map<String,String> map=new HashedMap();
			map.put(key, value);
			map.put(key+"_1", value+"_1");
			setBizConfigBean.setBizId(bizId);
			setBizConfigBean.setBizConfigMap(map);
				
			GodmchManageCallService.setBizConfig(setBizConfigBean);
			bean.setMchId(bizId);
			bean.setBizConfigKeys(Lists.newArrayList(key));
			call.setData(bean);
			call.callService();			
		
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchInfoForProductDetail_002() {
		Logger.start(true,"商户详情(买家端查询)-biz_key不存在");
		try {
			setBizConfigBean setBizConfigBean=GodmchManageCallService.initSetBizConfig();
			
	       // Integer bizId=Integer.parseInt(TestDataManager.getRandomNum(5));
	        Integer bizId=GodmchManageCallService.CreateSellerMch();
	        String key="key_"+TestDataManager.getRandomNum(5);
	        String value="value"+TestDataManager.getRandomNum(5);
			Map<String,String> map=new HashedMap();
			map.put(key, value);
			map.put(key+"_1", value+"_1");
			setBizConfigBean.setBizId(bizId);
			setBizConfigBean.setBizConfigMap(map);
				
			GodmchManageCallService.setBizConfig(setBizConfigBean);
			bean.setMchId(bizId);
			bean.setBizConfigKeys(Lists.newArrayList(key+1));
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}